package com.zygh.policeasset.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.zygh.policeasset.component.CommonResult;
import com.zygh.policeasset.pojo.AppVersionUploadFile;
import com.zygh.policeasset.pojo.VersionManagement;
import com.zygh.policeasset.service.VersionManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = {"APP版本控制"})
@RequestMapping({"versionManagement"})
@RestController
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/controller/VersionManagementController.class */
public class VersionManagementController {
    @Resource
    VersionManagementService versionManagementService;

    @GetMapping({"selectOne"})
    @ApiOperation("通过ID查询")
    public VersionManagement selectOne(Integer id) {
        return this.versionManagementService.queryById(id);
    }

    @GetMapping({"queryAll"})
    @ApiOperation("分页查询全部")
    public PageInfo queryAll(@RequestParam(defaultValue = "1", value = "pageNum") Integer pageNum, @RequestParam(defaultValue = "10", value = "pageSize") Integer pageSize, VersionManagement versionManagement) {
        return this.versionManagementService.queryAll(pageNum.intValue(), pageSize.intValue(), versionManagement);
    }

    @PostMapping({"insert"})
    @ApiOperation("添加")
    public CommonResult insert(@RequestBody VersionManagement versionManagement) {
        return this.versionManagementService.insert(versionManagement);
    }

    @PostMapping({"update"})
    @ApiOperation("修改")
    public CommonResult update(@RequestBody VersionManagement versionManagement) {
        return this.versionManagementService.update(versionManagement);
    }

    @DeleteMapping({"/delete/{id}"})
    @ApiOperation("根据id删除")
    public CommonResult delete(@PathVariable Integer id) {
        return this.versionManagementService.deleteById(id);
    }

    @GetMapping({"/checkVersion"})
    @ApiOperation("检查是否是最新版本")
    public Object checkVersion(@RequestParam Integer editionNum) {
        return this.versionManagementService.checkVersion(editionNum);
    }

    @PostMapping({"/uploadFile"})
    @ApiOperation("上传附件")
    public Object uploadFile(AppVersionUploadFile appVersionUploadFile) {
        return this.versionManagementService.uploadFile(appVersionUploadFile);
    }

    @DeleteMapping({"/remove"})
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键", required = true, paramType = "query"), @ApiImplicitParam(name = "url", value = "上传地址", required = true, paramType = "query")})
    @ApiOperation("删除文件")
    public Object remove(@RequestBody JSONObject json) {
        return this.versionManagementService.remove(json.getInteger("id"), json.getString("url"));
    }
}